package org.hk.kg.finance.stuclz.action;

import java.util.Map;
import java.util.Map.Entry;

import org.hk.kg.db.DBServiceProxy;
import org.hk.kg.finance.FinanceConstants;
import org.hk.kg.finance.stuclz.service.IStuClzService;
import org.hk.kg.finance.stuclz.service.StuClzService;
import org.hk.kg.ui.ParamsStack;
import org.hk.kg.utils.Constants;
import org.hk.kg.web.BaseAction;

public class ModifyStuClzAction extends BaseAction {
	private IStuClzService stuClzServ = DBServiceProxy.getProxyClz(StuClzService.class);
	public String doSave(ParamsStack stack)
	{
		Integer clzId = Integer.valueOf(stack.getValue("clzId"));
		String clzName = stack.getValue("clzName"),
			clzType = stack.getValue("clzType");
		stuClzServ.modifyStuClz(clzId, clzName, clzType);
		return "stu_clz_page";
	}
	
	public String getStuClzTypes()
	{
		Map<String, String> clzTypes = Constants.CONFIG.getGroup(FinanceConstants.CLZ_TYPE_CONSTANTS);
		StringBuffer buffer = new StringBuffer();
		for(Entry<String, String> entry : clzTypes.entrySet())
		{
			String selected = "";
			if(entry.getKey().equals(""+this.getParams().get("stuClzType")))
			{
				selected = " selected=\"selected\" ";
			}
			buffer.append("<option value=\"").append(entry.getKey()).append(selected).append("\">")
			.append(entry.getValue()).append("</option>\n");
		}
		return buffer.toString();
	}
}
